<!-- <script>
import { ref, onMounted } from 'vue';
import { getSupplierAllStatistics, supplierUnBind } from "../api/my";
import { useRouter } from "vue-router";
import { removeToken } from "@/utils/auth";
import { showDialog, showConfirmDialog, showLoadingToast } from 'vant';




export default {
    setup() {
        const active = ref(0);
        const user1 = localStorage.getItem('user');
        const user = JSON.parse(user1)
        const router = useRouter();
        onMounted(() => {

        });
        const jiechubangding = () => {
            showConfirmDialog({
                title: '提示',
                message:
                    '确定要注销嘛？',
            }).then(() => {
                showLoadingToast({
                    message: '加载中...',
                    forbidClick: true,
                    loadingType: 'spinner',
                });
                supplierUnBind({}).then((res) => {
                    if (res.result === 0) {
                        removeToken();
                        router.push({ path: "/login" });
                    }
                });
            })
                .catch(() => {
                });
        }
        return {
            jiechubangding,
            active,
            user
        };
    }
}
</script>
<template>
    <div style="padding: 15px;">
        <div>
            <img src="../../img/orders-ok.png" style="width: 100px;">
            <van-swipe-cell style="width: 300px;height: 100px;;float: right;">
                <van-cell :border="true" style="height: 50px;" title-style="font-weight: bold;" :title="user.name"
                    :value="user.name" />
                <van-cell :border="true" style="height: 50px;" :title="user.account" />
            </van-swipe-cell>
        </div>
        <div>
            <hr style="width: 100%;">
            <van-cell title="门店设置" title-style="font-weight: bold;" is-link to="mendian" />
            <van-cell title="账号设置" title-style="font-weight: bold;" is-link to="zhanghao" />
            <hr style="width: 100%;">
            <van-button type="primary" style="margin-top: 20px;" @click="jiechubangding()" size="large">解除绑定</van-button>
        </div>
        <div>
        </div>
    </div>

</template> -->
<script>
import { ref, onMounted, watchEffect, reactive, toRefs } from "vue";
import {
    getSupplierAllStatistics,
    supplierUnBind,
    getSupplierInfo,
} from "../api/my";
import { useRouter } from "vue-router";
import { removeToken } from "@/utils/auth";
import { showDialog, showConfirmDialog, showLoadingToast } from "vant";

export default {
    setup() {
        const active = ref(0);
        const user1 = localStorage.getItem("user");
        const user = JSON.parse(user1);
        const router = useRouter();
        const data = reactive({
            data: [],
            loading: true
        });

        const methods = {
            bindUser() {
                getSupplierInfo({}).then((res) => {
                    if (res.result === 0) {
                        data.data = res.data;
                        data.loading = false;

                    }
                });
            },
        };

        watchEffect(() => {
            methods.bindUser();
        });

        onMounted(() => { });
        const jiechubangding = () => {
            showConfirmDialog({
                title: "提示",
                message: "确定要注销嘛？",
            })
                .then(() => {
                    showLoadingToast({
                        message: "加载中...",
                        forbidClick: true,
                        loadingType: "spinner",
                    });
                    supplierUnBind({}).then((res) => {
                        if (res.result === 0) {
                            removeToken();
                            router.push({ path: "/login" });
                        }
                    });
                })
                .catch(() => { });
        };
        return {
            ...toRefs(data),
            jiechubangding,
            active,
            user,
        };
    },
};
</script>
<template>
    <van-skeleton title :row="8" :loading="loading" style="margin: 5px;">
        <div style="padding: 5px">
            <div style="display: flex">
                <div class="img">
                    <img style="width: 120px; padding-top: 10px" :src="data.slogo" />
                </div>
                <div style="flex: 1">
                    <van-cell :border="true" style="height: 50px" title-style="font-weight: bold;" :title="user.name"
                        :value="user.name" />
                    <van-cell :border="true" style="height: 50px" :title="user.account" />
                </div>
            </div>
            <div>
                <hr style="width: 100%" />
                <van-cell title="门店设置" title-style="font-weight: bold;" is-link to="mendian" />
                <van-cell title="账号设置" title-style="font-weight: bold;" is-link to="zhanghao" />
                <hr style="width: 100%" />
                <van-button type="primary" style="margin-top: 20px" @click="jiechubangding()"
                    size="large">解除绑定</van-button>
            </div>
            <div></div>
        </div>
    </van-skeleton>
</template>

<style scoped>
.img {
    width: 120px;
}
</style>
